<?php
    class partit{
    	private $id;
    	private $data;
		private $equip1;
		private $equip2;
		private $restriccions;
		private $prioritat;
		
		function __constructor(){
			$this->equip1 = new equip();
			$this->equip2 = new equip();
			$this->equip1->setDadesBasic("-","-",0);
			$this->equip2->setDadesBasic("-","-",0);
		}
		
		public function setEquips($eq1, $eq2){
			$this->equip1 = $eq1;
			$this->equip2 = $eq2;
		}
		
		public function getEquip1(){
			return $this->equip1;
		}
		
		public function getEquip2(){
			return $this->equip2;
		}
		
		public function setId($id){
			$this->id = $id;
		}
		
		public function getId(){
			return $this->id;
		}
		
		public function getCat(){
			return $this->equip1->getCat();
		}
		
		public function getPrioritat(){
			return $this->prioritat;
		}
		
		public function setPrioritat($pr){
			$this->prioritat = $pr;
		}
		
		public function setRestriccions($res1, $res2){
			// Inicialitzar restriccions a false.. (opcional?¿)
			$n_dies = sizeof($res1);
			$this->restriccions = array();
			for ($i=0; $i < $n_dies; $i++) { 
				$this->restriccions[$i] = array();
				for ($j=0; $j < 3; $j++) { 
					$this->restriccions[$i][$j] = FALSE;
				}
			}
			
			// Posar restriccions
			for ($i=0; $i < sizeof($res1); $i++) { 
				for ($j=0; $j < 3; $j++) { 
					if($res1[$i][$j])		$this->restriccions[$i][$j] = TRUE;
					else if($res2[$i][$j])	$this->restriccions[$i][$j] = TRUE;
				}
			}
			
		}
		
		public function getPart(){
			return array_merge($this->equip1->getPart(), $this->equip2->getPart());
		}
		
		public function getNumRes(){
			$ret = 0;
			$n_dies = sizeof($this->restriccions);
			for ($i=0; $i < $n_dies; $i++) { 
				for ($j=0; $j < 3; $j++) { 
					if($this->restriccions[$i][$j])	$ret++;
				}
			}
			return $ret;
		}
		
		public function esPotJugar($data){
			$in = $data->getHoraIni();
			if($in < 13)		$h = 0;
			else if($in < 17)	$h = 1;
			else 				$h = 2;
			
			return !$this->restriccions[$data->getDia()][$h];
		}
		
    }
	
?>